Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: throw reject when SingleThreadExecutor drainTo in progress and queue is empty #4488

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nodece
Copy link
Member

@nodece nodece commented Aug 24, 2024

Fix #4465

Motivaction

In SingleThreadExecutor, the runner drains the full queue into the localTasks, when the localTasks has not been run, the queue is really full(the queue is empty in the memory) at this point.

When calling the execute() method, which shouldn't add the runnable to the queue, which would double the actual number of runable, increasing memory usage and potential OOM issues.

Changes

Add a variable to record the runnable count:

  • When we add the runnable to the queue, the value is increased by 1.
  • When we run the runnable, the value is reduced by 1.

@nodece nodece force-pushed the fix-SingleThreadExecutor-reject branch from cd0eeb9 to 3de037f Compare August 25, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant